﻿
$url = "https://api.exchangerate-api.com/v4/latest/CNY"
$response = Invoke-WebRequest -Uri $url

# 解析 JSON 数据
$data = $response.Content | ConvertFrom-Json

# 获取美元汇率
[decimal]$usdRate = $data.rates.USD

$大 = 1 / 6 # 0.16666
$小 = 1 / 8 # 0.125
if ( ($usdRate -gt 0) -and ($usdRate -gt $小) -and ($usdRate -lt $大) )
{
    return $usdRate
}
else
{
    Write-Error '错误：转换出错，返回码1'
    exit 1
}
exit 0
